"""
@author: lyf
@file: 链表的翻转.py
@time: 2022/12/7 18:45
"""
class Node(object):
    def __init__(self, value=None, next=None):
        self.value = value
        self.next = next


def re(link):
    now_node = link
    new_link = None
    while now_node != None:
        median = now_node.next
        now_node.next = new_link
        new_link = now_node
        now_node = median
    return new_link


link = Node(1, Node(2, Node(3, Node(4, Node(5)))))
root = re(link)
while root:
    print(root.value)
    root = root.next